package com.fosung.frame.modules.sys.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JSONHelper {
	private static Gson gson = new GsonBuilder().setDateFormat( "yyyy-MM-dd HH:mm" ).create();

    public static String toJSONString(Object object) {
        return gson.toJson(object);
    }

    public static <T> T fromJSONString(String jsonString, Class<T> clazz) {
        return gson.fromJson(jsonString, clazz);
    }

    public static <T> T convert(Object object, Class<T> clazz) {
        String jsonString = toJSONString(object);
        return fromJSONString(jsonString, clazz);
    }

}
